package cn.hpclub.server.validator.admin;

import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;

import cn.hpclub.server.model.Themes;

public class ThemesValidator extends Validator {

	@Override
	protected void validate(Controller c) {
		validateRequiredString("themes.name", "themesNameMessages", "主题名称不能为空");
		this.setShortCircuit(true);
		validateRequiredString("themes.sort", "themesSort", "排序不能为空");
        validateRegex("themes.sort", "^\\d+$", "themesSort", "排序只能是纯数字");
	}

	@Override
	protected void handleError(Controller c) {
		c.keepModel(Themes.class);
		c.setAttr("isChecked", c.getPara("themes.enabled"));
		c.render("/admin/themes_input.html");
	}
}
